#ifndef LIBRARY_H
#define LIBRARY_H

#include <QObject>
#include <QVector>
#include <QMutex>

typedef int book_id_t;

class Library : public QObject
{
    Q_OBJECT

    QVector<QMutex*> mutexes;
    QMutex booksMutex;

    int m_capacity;

public:
    explicit Library(int capacity);
    int size();

    bool takeBookForReading(book_id_t id);
    void returnReadBook(book_id_t id);
    book_id_t reserveBookToWrite();
    void publishWrittenBook(book_id_t id);
    void takeBookForEditing(book_id_t id);
    void returnEditedBook(book_id_t id);

    
signals:
    void finishedWritingBook();
    void waitingForBook();
    void finishedEditingBook();
    
public slots:
    
};

#endif // LIBRARY_H
